﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace _46递归输出文件路径
{
    class Program
    {
        static void Main(string[] args)
        {
            ScanFile(@"E:\U\C#");
        }
        static void ScanFile(string directory)
        {
            //获取当前文件夹下面的所有文件
            string[] files = Directory.GetFiles(directory);
            for (int i = 0; i < files.Length; i++)
            {
                Console.WriteLine(files[i]);

            }
            //获取当前文件夹下面的所有子文件夹
            string[] subDirs = Directory.GetDirectories(directory);
            //对所有子文件夹执行相同操作
            for (int i = 0; i < subDirs.Length; i++)
            {
                ScanFile(subDirs[i]);
            }
        }
    }
}
